<template>
  <div>
    <van-row>
      <van-col span="8"></van-col>
      <van-col span="8"><van-field label="请输入用户名" v-model="name" /></van-col>
      <van-col span="8"></van-col>
    </van-row>
    <van-row>
      <van-col span="8"></van-col>
      <van-col span="8"><van-field label="请输入密码" v-model="password" /></van-col>
      <van-col span="8"></van-col>
    </van-row>
    <van-row>
      <van-col span="8"></van-col>
      <van-col span="8"><van-button @click="login">点击登录</van-button></van-col>
      <van-col span="8"></van-col>
    </van-row>
  </div>
</template>

<script>
import myaxios from "../../https/myaxios";
export default {
  name: "login",
  data(){
    return{
      name:'',
      password:''
    }
  },
  methods:{
    login(){
      myaxios("/login?user="+this.name+"&pwd="+this.password,"get").then(res=>{
        if(res.code==200){
          this.$toast.success("登陆成功")
          localStorage.setItem("userid",res.userid)
          localStorage.setItem("token",res.token)
          localStorage.setItem("vurl",JSON.stringify(res.vurl))
          this.$router.push("/manage")
        }else {
          this.$toast.fail("登陆失败")
        }
      })
    }
  },
}
</script>

<style scoped>

</style>